//DHCOutPhPrescNoTJ
//
var tblobj=document.getElementById("tDHCOutPhPrescNoTJ");
var evtName;
var doneInit=0;
var focusat=null;
var SelectedRow = 0;
var pmiobj,pnameobj;
var stdateobj,enddateobj;
var phlobj,phwobj,locdescobj,phwdescobj,pydrobj,fydrobj,pynameobj,fynameobj;
var ctlocobj,useridobj;
var BResetobj,BPrintobj;
var printobj;

function BodyLoadHandler() {
  BResetobj=document.getElementById("BReset");
  if (BResetobj) BResetobj.onclick=Reset_click;
 var BPrintobj=document.getElementById("BPrint");
  if (BPrintobj) BPrintobj.onclick=Print_click;
  ctlocobj=document.getElementById("ctloc");



}

function SelectRowHandler()	{
	
	var eSrc=window.event.srcElement;
	if (eSrc.tagName=="IMG") eSrc=window.event.srcElement.parentElement;
	var eSrcAry=eSrc.id.split("z");
	var rowObj=getRow(eSrc);
	var selectrow=rowObj.rowIndex;
	if (!selectrow) return;
	SelectedRow = selectrow;

}


function Reset_click()
{
	location.href="websys.default.csp?WEBSYS.TCOMPONENT=DHCOutPhPrescNoTJ";
 }

function GetTypeID(value)
{
  var sstr=value.split("^")
  var fydrobj=document.getElementById("CPrescTypeID")
    fydrobj.value=sstr[1]
}
function GCatID(value)
{
  var sstr=value.split("^")
  var fydrobj=document.getElementById("CIncCatID")
     fydrobj.value=sstr[1]
    
     
}
function GPhCatID(value)
{
  var sstr=value.split("^")
  var fydrobj=document.getElementById("CPhCatID")
     fydrobj.value=sstr[1]
    

}
 function Print_click(){
	 tblobj=document.getElementById("tDHCOutPhPrescNoTJ");
	 if (tblobj.rows.length==0) {alert(t['01']);return 0;}
	 var rows,pagerow;
	 rows=tblobj.rows.length-1
	 var path
	   pagerow=35;
     var Ls_orderitemtmp,RowN,i
      var getmethod=document.getElementById('gpath');
      if (getmethod) {var encmeth=getmethod.value} else {var encmeth=''};
      path=cspRunServerMethod(encmeth)
     var datest=document.getElementById('CDateSt');
	 var dateend=document.getElementById('CDateEnd');
	  var getmethod=document.getElementById('ghosname');
      if (getmethod) {var encmeth=getmethod.value} else {var encmeth=''};
     var hosname=cspRunServerMethod(encmeth)

	  var xlApp,obook,osheet,xlsheet,xlBook
	    var paymoney
        var Template
        Template=path+"yfcftj.xls"
        xlApp = new ActiveXObject("Excel.Application");
	    xlBook = xlApp.Workbooks.Add(Template);
	    xlsheet = xlBook.ActiveSheet
	    //xlsheet.cells(1,1).value=hosname
        xlsheet.cells(2,8).value=datest.value+"--"+dateend.value
    
       for(i=1;i<=rows;i++){
		  xlsheet.cells(3+i,1).value=document.getElementById("TPrescTypez"+i).innerText
		  xlsheet.cells(3+i,2).value=document.getElementById("TPrescNumz"+i).innerText
	 	  xlsheet.cells(3+i,3).value=document.getElementById("TPrescTotalz"+i).innerText
	 	  xlsheet.cells(3+i,4).value=document.getElementById("TPrescBLz"+i).innerText
	 	  xlsheet.cells(3+i,5).value=document.getElementById("TPrescMaxPmiz"+i).innerText
	 	  xlsheet.cells(3+i,6).value=document.getElementById("TPrescMinPmiz"+i).innerText
	 	  xlsheet.cells(3+i,7).value=document.getElementById("TPrescMaxMoneyz"+i).innerText
	 	  xlsheet.cells(3+i,8).value=document.getElementById("TPrescMinMoneyz"+i).innerText 
	 	  xlsheet.cells(3+i,9).value=document.getElementById("TPrescMoneyz"+i).innerText
	 	  xlsheet.cells(3+i,10).value=document.getElementById("TPrescPhNumz"+i).innerText
	 	  xlsheet.cells(3+i,11).value=document.getElementById("TCYFSz"+i).innerText
	 	  xlsheet.cells(3+i,12).value=document.getElementById("TJYFSz"+i).innerText
	 	  xlsheet.cells(3+i,13).value=document.getElementById("TJYCFz"+i).innerText

	 	  xlsheet.Range(xlsheet.Cells(3,1), xlsheet.Cells((3+i),13)).Borders(1).LineStyle=1;
	      xlsheet.Range(xlsheet.Cells(3,1), xlsheet.Cells((3+i),13)).Borders(2).LineStyle=1;
	      xlsheet.Range(xlsheet.Cells(3,1), xlsheet.Cells((3+i),13)).Borders(3).LineStyle=1;
          xlsheet.Range(xlsheet.Cells(3,1), xlsheet.Cells((3+i),13)).Borders(4).LineStyle=1;
	 }
    xlsheet.printout
	xlBook.Close(savechanges=false);
	xlApp=null;
	xlsheet=null

   }	   


document.body.onload = BodyLoadHandler;
